package hot100.logos31To40;

import hot100.datastruct.TreeNode;

/**
 * @author logos
 * date 2025/7/13 13:07
 * @version v1.0
 * @Package hot100.logos31To40
 */
public class logos38 {

    /**
     * 38. 翻转二叉树
     * https://leetcode.cn/problems/invert-binary-tree/description/?envType=study-plan-v2&envId=top-100-liked
     */
    class Solution {
        public TreeNode invertTree(TreeNode root) {
            if (root == null) {
                return null;
            }
            TreeNode left = invertTree(root.left);
            TreeNode right = invertTree(root.right);
            root.left = right;
            root.right = left;
            return root;
        }
    }
}
